#include "Trigonometric.h"

#define ABS(x) ((x) > 0 ? (x) : -(x))

int Dichotomization_Lookup_Angle(int left, int right, const float *form, float solution);

//sin值,0-90°，间隔0.1°
const float sin_lookup[] = {
	0.0000000, 0.0017453, 0.0034907, 0.0052360, 0.0069813, 0.0087265, 0.0104718, 0.0122170, 0.0139622, 0.0157073,
	0.0174524, 0.0191974, 0.0209424, 0.0226873, 0.0244322, 0.0261770, 0.0279216, 0.0296662, 0.0314108, 0.0331552,
	0.0348995, 0.0366437, 0.0383878, 0.0401318, 0.0418757, 0.0436194, 0.0453630, 0.0471065, 0.0488498, 0.0505929,
	0.0523360, 0.0540788, 0.0558215, 0.0575640, 0.0593064, 0.0610485, 0.0627905, 0.0645323, 0.0662739, 0.0680153,
	0.0697565, 0.0714974, 0.0732382, 0.0749787, 0.0767190, 0.0784591, 0.0801989, 0.0819385, 0.0836778, 0.0854169,
	0.0871557, 0.0888943, 0.0906326, 0.0923706, 0.0941083, 0.0958458, 0.0975829, 0.0993198, 0.1010563, 0.1027925,
	0.1045285, 0.1062641, 0.1079994, 0.1097343, 0.1114689, 0.1132032, 0.1149372, 0.1166707, 0.1184040, 0.1201368,
	0.1218694, 0.1236015, 0.1253332, 0.1270646, 0.1287956, 0.1305262, 0.1322564, 0.1339862, 0.1357156, 0.1374446,
	0.1391731, 0.1409012, 0.1426289, 0.1443562, 0.1460830, 0.1478094, 0.1495353, 0.1512608, 0.1529858, 0.1547104,
	0.1564345, 0.1581581, 0.1598812, 0.1616038, 0.1633260, 0.1650476, 0.1667687, 0.1684894, 0.1702095, 0.1719291,
	0.1736482, 0.1753667, 0.1770847, 0.1788022, 0.1805191, 0.1822355, 0.1839514, 0.1856666, 0.1873813, 0.1890954,
	0.1908090, 0.1925220, 0.1942344, 0.1959462, 0.1976573, 0.1993679, 0.2010779, 0.2027873, 0.2044961, 0.2062042,
	0.2079117, 0.2096186, 0.2113248, 0.2130304, 0.2147353, 0.2164396, 0.2181432, 0.2198462, 0.2215485, 0.2232501,
	0.2249511, 0.2266513, 0.2283509, 0.2300497, 0.2317479, 0.2334454, 0.2351421, 0.2368381, 0.2385335, 0.2402280,
	0.2419219, 0.2436150, 0.2453074, 0.2469990, 0.2486899, 0.2503800, 0.2520694, 0.2537580, 0.2554458, 0.2571328,
	0.2588191, 0.2605045, 0.2621892, 0.2638731, 0.2655561, 0.2672384, 0.2689198, 0.2706005, 0.2722803, 0.2739592,
	0.2756374, 0.2773147, 0.2789911, 0.2806667, 0.2823415, 0.2840154, 0.2856884, 0.2873605, 0.2890318, 0.2907022,
	0.2923717, 0.2940403, 0.2957081, 0.2973749, 0.2990408, 0.3007058, 0.3023699, 0.3040331, 0.3056953, 0.3073566,
	0.3090170, 0.3106764, 0.3123349, 0.3139925, 0.3156490, 0.3173047, 0.3189593, 0.3206130, 0.3222657, 0.3239174,
	0.3255682, 0.3272179, 0.3288667, 0.3305144, 0.3321611, 0.3338069, 0.3354516, 0.3370953, 0.3387379, 0.3403796,
	0.3420202, 0.3436597, 0.3452982, 0.3469357, 0.3485721, 0.3502074, 0.3518417, 0.3534749, 0.3551070, 0.3567380,
	0.3583680, 0.3599968, 0.3616246, 0.3632512, 0.3648768, 0.3665013, 0.3681246, 0.3697468, 0.3713679, 0.3729878,
	0.3746066, 0.3762243, 0.3778408, 0.3794562, 0.3810704, 0.3826835, 0.3842954, 0.3859061, 0.3875156, 0.3891240,
	0.3907311, 0.3923371, 0.3939419, 0.3955455, 0.3971479, 0.3987491, 0.4003491, 0.4019478, 0.4035453, 0.4051416,
	0.4067367, 0.4083305, 0.4099231, 0.4115144, 0.4131045, 0.4146933, 0.4162808, 0.4178671, 0.4194521, 0.4210358,
	0.4226183, 0.4241994, 0.4257793, 0.4273579, 0.4289351, 0.4305111, 0.4320858, 0.4336591, 0.4352311, 0.4368018,
	0.4383712, 0.4399392, 0.4415059, 0.4430712, 0.4446352, 0.4461978, 0.4477591, 0.4493190, 0.4508776, 0.4524347,
	0.4539905, 0.4555449, 0.4570980, 0.4586496, 0.4601998, 0.4617486, 0.4632961, 0.4648421, 0.4663867, 0.4679298,
	0.4694716, 0.4710119, 0.4725508, 0.4740882, 0.4756242, 0.4771588, 0.4786919, 0.4802235, 0.4817537, 0.4832824,
	0.4848096, 0.4863354, 0.4878597, 0.4893825, 0.4909038, 0.4924236, 0.4939419, 0.4954587, 0.4969740, 0.4984878,
	0.5000000, 0.5015107, 0.5030200, 0.5045276, 0.5060338, 0.5075384, 0.5090414, 0.5105429, 0.5120429, 0.5135413,
	0.5150381, 0.5165333, 0.5180270, 0.5195192, 0.5210096, 0.5224986, 0.5239859, 0.5254717, 0.5269558, 0.5284383,
	0.5299193, 0.5313986, 0.5328763, 0.5343524, 0.5358268, 0.5372996, 0.5387708, 0.5402404, 0.5417082, 0.5431745,
	0.5446391, 0.5461020, 0.5475633, 0.5490229, 0.5504808, 0.5519370, 0.5533916, 0.5548444, 0.5562956, 0.5577451,
	0.5591929, 0.5606390, 0.5620834, 0.5635260, 0.5649670, 0.5664063, 0.5678437, 0.5692796, 0.5707136, 0.5721459,
	0.5735765, 0.5750053, 0.5764324, 0.5778576, 0.5792812, 0.5807030, 0.5821230, 0.5835412, 0.5849577, 0.5863724,
	0.5877853, 0.5891964, 0.5906057, 0.5920132, 0.5934189, 0.5948228, 0.5962249, 0.5976251, 0.5990236, 0.6004202,
	0.6018151, 0.6032080, 0.6045991, 0.6059885, 0.6073759, 0.6087614, 0.6101452, 0.6115270, 0.6129071, 0.6142852,
	0.6156615, 0.6170359, 0.6184084, 0.6197791, 0.6211478, 0.6225147, 0.6238796, 0.6252427, 0.6266039, 0.6279631,
	0.6293204, 0.6306758, 0.6320293, 0.6333809, 0.6347305, 0.6360782, 0.6374240, 0.6387678, 0.6401097, 0.6414496,
	0.6427876, 0.6441237, 0.6454577, 0.6467898, 0.6481199, 0.6494480, 0.6507743, 0.6520984, 0.6534206, 0.6547408,
	0.6560590, 0.6573753, 0.6586895, 0.6600017, 0.6613119, 0.6626201, 0.6639263, 0.6652304, 0.6665325, 0.6678326,
	0.6691306, 0.6704266, 0.6717206, 0.6730126, 0.6743024, 0.6755902, 0.6768760, 0.6781597, 0.6794413, 0.6807209,
	0.6819984, 0.6832738, 0.6845471, 0.6858184, 0.6870875, 0.6883546, 0.6896196, 0.6908825, 0.6921432, 0.6934019,
	0.6946584, 0.6959128, 0.6971651, 0.6984153, 0.6996634, 0.7009093, 0.7021531, 0.7033947, 0.7046343, 0.7058716,
	0.7071068, 0.7083399, 0.7095708, 0.7107995, 0.7120261, 0.7132505, 0.7144727, 0.7156928, 0.7169106, 0.7181263,
	0.7193398, 0.7205511, 0.7217603, 0.7229672, 0.7241719, 0.7253744, 0.7265747, 0.7277728, 0.7289686, 0.7301623,
	0.7313537, 0.7325429, 0.7337299, 0.7349146, 0.7360971, 0.7372773, 0.7384554, 0.7396311, 0.7408046, 0.7419759,
	0.7431449, 0.7443116, 0.7454760, 0.7466382, 0.7477981, 0.7489557, 0.7501111, 0.7512642, 0.7524150, 0.7535634,
	0.7547096, 0.7558535, 0.7569951, 0.7581344, 0.7592713, 0.7604060, 0.7615383, 0.7626684, 0.7637960, 0.7649214,
	0.7660444, 0.7671652, 0.7682836, 0.7693996, 0.7705132, 0.7716246, 0.7727336, 0.7738403, 0.7749445, 0.7760464,
	0.7771460, 0.7782432, 0.7793380, 0.7804304, 0.7815205, 0.7826082, 0.7836935, 0.7847764, 0.7858569, 0.7869350,
	0.7880108, 0.7890841, 0.7901551, 0.7912235, 0.7922897, 0.7933534, 0.7944146, 0.7954735, 0.7965300, 0.7975839,
	0.7986356, 0.7996847, 0.8007314, 0.8017756, 0.8028175, 0.8038569, 0.8048938, 0.8059283, 0.8069604, 0.8079899,
	0.8090170, 0.8100417, 0.8110638, 0.8120836, 0.8131008, 0.8141155, 0.8151278, 0.8161376, 0.8171449, 0.8181498,
	0.8191521, 0.8201519, 0.8211492, 0.8221440, 0.8231364, 0.8241262, 0.8251135, 0.8260983, 0.8270806, 0.8280603,
	0.8290376, 0.8300123, 0.8309845, 0.8319541, 0.8329213, 0.8338859, 0.8348479, 0.8358074, 0.8367643, 0.8377187,
	0.8386706, 0.8396199, 0.8405666, 0.8415108, 0.8424524, 0.8433915, 0.8443279, 0.8452619, 0.8461932, 0.8471220,
	0.8480481, 0.8489717, 0.8498927, 0.8508111, 0.8517270, 0.8526402, 0.8535508, 0.8544589, 0.8553643, 0.8562671,
	0.8571673, 0.8580650, 0.8589599, 0.8598523, 0.8607420, 0.8616292, 0.8625137, 0.8633956, 0.8642748, 0.8651515,
	0.8660255, 0.8668968, 0.8677655, 0.8686316, 0.8694949, 0.8703557, 0.8712139, 0.8720693, 0.8729221, 0.8737723,
	0.8746197, 0.8754646, 0.8763067, 0.8771462, 0.8779830, 0.8788172, 0.8796486, 0.8804774, 0.8813035, 0.8821269,
	0.8829476, 0.8837656, 0.8845810, 0.8853936, 0.8862036, 0.8870109, 0.8878154, 0.8886172, 0.8894164, 0.8902128,
	0.8910065, 0.8917976, 0.8925858, 0.8933714, 0.8941543, 0.8949344, 0.8957118, 0.8964865, 0.8972584, 0.8980276,
	0.8987941, 0.8995578, 0.9003188, 0.9010770, 0.9018325, 0.9025853, 0.9033353, 0.9040825, 0.9048271, 0.9055688,
	0.9063078, 0.9070441, 0.9077775, 0.9085082, 0.9092361, 0.9099613, 0.9106837, 0.9114033, 0.9121201, 0.9128342,
	0.9135455, 0.9142540, 0.9149597, 0.9156626, 0.9163628, 0.9170601, 0.9177547, 0.9184464, 0.9191353, 0.9198215,
	0.9205049, 0.9211854, 0.9218631, 0.9225381, 0.9232102, 0.9238796, 0.9245461, 0.9252097, 0.9258706, 0.9265286,
	0.9271839, 0.9278362, 0.9284858, 0.9291326, 0.9297765, 0.9304176, 0.9310559, 0.9316912, 0.9323238, 0.9329535,
	0.9335805, 0.9342045, 0.9348257, 0.9354441, 0.9360595, 0.9366722, 0.9372820, 0.9378889, 0.9384930, 0.9390943,
	0.9396926, 0.9402881, 0.9408808, 0.9414706, 0.9420575, 0.9426415, 0.9432227, 0.9438010, 0.9443764, 0.9449489,
	0.9455186, 0.9460854, 0.9466493, 0.9472103, 0.9477685, 0.9483237, 0.9488760, 0.9494255, 0.9499720, 0.9505158,
	0.9510565, 0.9515944, 0.9521294, 0.9526615, 0.9531907, 0.9537169, 0.9542403, 0.9547608, 0.9552784, 0.9557930,
	0.9563048, 0.9568136, 0.9573195, 0.9578225, 0.9583226, 0.9588198, 0.9593140, 0.9598053, 0.9602937, 0.9607792,
	0.9612617, 0.9617413, 0.9622180, 0.9626918, 0.9631626, 0.9636304, 0.9640954, 0.9645574, 0.9650165, 0.9654726,
	0.9659258, 0.9663761, 0.9668234, 0.9672678, 0.9677092, 0.9681476, 0.9685832, 0.9690157, 0.9694454, 0.9698720,
	0.9702957, 0.9707165, 0.9711343, 0.9715492, 0.9719610, 0.9723699, 0.9727759, 0.9731789, 0.9735789, 0.9739760,
	0.9743701, 0.9747612, 0.9751493, 0.9755346, 0.9759168, 0.9762960, 0.9766723, 0.9770456, 0.9774159, 0.9777833,
	0.9781476, 0.9785090, 0.9788674, 0.9792228, 0.9795753, 0.9799247, 0.9802712, 0.9806147, 0.9809552, 0.9812927,
	0.9816272, 0.9819588, 0.9822873, 0.9826128, 0.9829354, 0.9832549, 0.9835715, 0.9838851, 0.9841956, 0.9845032,
	0.9848078, 0.9851093, 0.9854079, 0.9857035, 0.9859961, 0.9862856, 0.9865722, 0.9868558, 0.9871363, 0.9874138,
	0.9876884, 0.9879599, 0.9882284, 0.9884939, 0.9887564, 0.9890159, 0.9892724, 0.9895258, 0.9897763, 0.9900237,
	0.9902681, 0.9905095, 0.9907479, 0.9909832, 0.9912155, 0.9914449, 0.9916712, 0.9918944, 0.9921147, 0.9923319,
	0.9925462, 0.9927573, 0.9929655, 0.9931707, 0.9933728, 0.9935719, 0.9937679, 0.9939610, 0.9941510, 0.9943380,
	0.9945219, 0.9947028, 0.9948807, 0.9950556, 0.9952274, 0.9953962, 0.9955620, 0.9957247, 0.9958844, 0.9960411,
	0.9961947, 0.9963453, 0.9964929, 0.9966374, 0.9967789, 0.9969173, 0.9970527, 0.9971851, 0.9973145, 0.9974408,
	0.9975641, 0.9976843, 0.9978015, 0.9979156, 0.9980267, 0.9981348, 0.9982398, 0.9983418, 0.9984408, 0.9985367,
	0.9986295, 0.9987193, 0.9988061, 0.9988899, 0.9989706, 0.9990482, 0.9991229, 0.9991944, 0.9992629, 0.9993284,
	0.9993909, 0.9994502, 0.9995065, 0.9995599, 0.9996101, 0.9996573, 0.9997015, 0.9997426, 0.9997807, 0.9998157,
	0.9998477, 0.9998766, 0.9999026, 0.9999254, 0.9999452, 0.9999619, 0.9999756, 0.9999863, 0.9999939, 0.9999985,
	1.0000000};

//cos值，0-90°，间隔0.1°
const float cos_lookup[] = {
	1.0000000, 0.9999985, 0.9999939, 0.9999863, 0.9999756, 0.9999619, 0.9999452, 0.9999254, 0.9999026, 0.9998766,
	0.9998477, 0.9998157, 0.9997807, 0.9997426, 0.9997015, 0.9996573, 0.9996101, 0.9995599, 0.9995065, 0.9994502,
	0.9993909, 0.9993284, 0.9992629, 0.9991944, 0.9991229, 0.9990482, 0.9989706, 0.9988899, 0.9988061, 0.9987193,
	0.9986295, 0.9985367, 0.9984408, 0.9983418, 0.9982398, 0.9981348, 0.9980267, 0.9979156, 0.9978015, 0.9976843,
	0.9975641, 0.9974408, 0.9973145, 0.9971851, 0.9970527, 0.9969173, 0.9967789, 0.9966374, 0.9964929, 0.9963453,
	0.9961947, 0.9960411, 0.9958844, 0.9957247, 0.9955620, 0.9953962, 0.9952274, 0.9950556, 0.9948807, 0.9947028,
	0.9945219, 0.9943379, 0.9941509, 0.9939610, 0.9937679, 0.9935719, 0.9933727, 0.9931707, 0.9929655, 0.9927573,
	0.9925462, 0.9923319, 0.9921147, 0.9918944, 0.9916712, 0.9914449, 0.9912155, 0.9909832, 0.9907479, 0.9905095,
	0.9902681, 0.9900237, 0.9897763, 0.9895258, 0.9892724, 0.9890159, 0.9887564, 0.9884939, 0.9882284, 0.9879599,
	0.9876884, 0.9874138, 0.9871363, 0.9868558, 0.9865722, 0.9862856, 0.9859960, 0.9857035, 0.9854079, 0.9851093,
	0.9848077, 0.9845032, 0.9841956, 0.9838851, 0.9835715, 0.9832549, 0.9829354, 0.9826128, 0.9822872, 0.9819587,
	0.9816272, 0.9812927, 0.9809552, 0.9806147, 0.9802712, 0.9799247, 0.9795753, 0.9792228, 0.9788674, 0.9785090,
	0.9781476, 0.9777833, 0.9774159, 0.9770456, 0.9766723, 0.9762960, 0.9759168, 0.9755346, 0.9751493, 0.9747612,
	0.9743701, 0.9739760, 0.9735789, 0.9731789, 0.9727759, 0.9723699, 0.9719610, 0.9715491, 0.9711343, 0.9707165,
	0.9702957, 0.9698720, 0.9694454, 0.9690157, 0.9685832, 0.9681476, 0.9677092, 0.9672678, 0.9668234, 0.9663761,
	0.9659258, 0.9654726, 0.9650165, 0.9645574, 0.9640954, 0.9636304, 0.9631626, 0.9626917, 0.9622180, 0.9617413,
	0.9612617, 0.9607791, 0.9602937, 0.9598053, 0.9593140, 0.9588198, 0.9583226, 0.9578225, 0.9573195, 0.9568136,
	0.9563047, 0.9557930, 0.9552783, 0.9547608, 0.9542403, 0.9537169, 0.9531907, 0.9526615, 0.9521294, 0.9515944,
	0.9510565, 0.9505158, 0.9499720, 0.9494255, 0.9488760, 0.9483237, 0.9477684, 0.9472103, 0.9466493, 0.9460853,
	0.9455186, 0.9449489, 0.9443764, 0.9438009, 0.9432227, 0.9426415, 0.9420574, 0.9414706, 0.9408808, 0.9402881,
	0.9396926, 0.9390943, 0.9384930, 0.9378889, 0.9372820, 0.9366722, 0.9360595, 0.9354441, 0.9348257, 0.9342045,
	0.9335804, 0.9329535, 0.9323238, 0.9316912, 0.9310558, 0.9304175, 0.9297765, 0.9291326, 0.9284858, 0.9278362,
	0.9271839, 0.9265286, 0.9258706, 0.9252097, 0.9245460, 0.9238795, 0.9232102, 0.9225381, 0.9218631, 0.9211854,
	0.9205049, 0.9198215, 0.9191353, 0.9184464, 0.9177547, 0.9170601, 0.9163627, 0.9156626, 0.9149597, 0.9142540,
	0.9135454, 0.9128342, 0.9121201, 0.9114033, 0.9106836, 0.9099613, 0.9092361, 0.9085082, 0.9077775, 0.9070440,
	0.9063078, 0.9055688, 0.9048271, 0.9040825, 0.9033353, 0.9025853, 0.9018325, 0.9010770, 0.9003188, 0.8995578,
	0.8987941, 0.8980276, 0.8972584, 0.8964864, 0.8957118, 0.8949344, 0.8941543, 0.8933714, 0.8925858, 0.8917976,
	0.8910065, 0.8902128, 0.8894164, 0.8886172, 0.8878154, 0.8870108, 0.8862036, 0.8853936, 0.8845810, 0.8837656,
	0.8829476, 0.8821269, 0.8813034, 0.8804774, 0.8796486, 0.8788171, 0.8779830, 0.8771462, 0.8763067, 0.8754645,
	0.8746197, 0.8737722, 0.8729221, 0.8720692, 0.8712138, 0.8703557, 0.8694949, 0.8686315, 0.8677654, 0.8668968,
	0.8660254, 0.8651514, 0.8642748, 0.8633956, 0.8625137, 0.8616291, 0.8607420, 0.8598523, 0.8589599, 0.8580649,
	0.8571673, 0.8562671, 0.8553643, 0.8544588, 0.8535508, 0.8526402, 0.8517270, 0.8508111, 0.8498927, 0.8489717,
	0.8480481, 0.8471219, 0.8461931, 0.8452618, 0.8443279, 0.8433914, 0.8424524, 0.8415108, 0.8405666, 0.8396199,
	0.8386706, 0.8377187, 0.8367643, 0.8358073, 0.8348479, 0.8338858, 0.8329212, 0.8319541, 0.8309845, 0.8300123,
	0.8290376, 0.8280603, 0.8270806, 0.8260983, 0.8251135, 0.8241262, 0.8231363, 0.8221440, 0.8211492, 0.8201519,
	0.8191521, 0.8181497, 0.8171449, 0.8161376, 0.8151278, 0.8141155, 0.8131008, 0.8120836, 0.8110638, 0.8100416,
	0.8090170, 0.8079899, 0.8069603, 0.8059283, 0.8048938, 0.8038569, 0.8028175, 0.8017756, 0.8007314, 0.7996847,
	0.7986355, 0.7975839, 0.7965299, 0.7954735, 0.7944146, 0.7933533, 0.7922896, 0.7912235, 0.7901550, 0.7890841,
	0.7880107, 0.7869350, 0.7858569, 0.7847763, 0.7836934, 0.7826082, 0.7815205, 0.7804304, 0.7793380, 0.7782431,
	0.7771459, 0.7760464, 0.7749445, 0.7738402, 0.7727336, 0.7716246, 0.7705132, 0.7693995, 0.7682835, 0.7671651,
	0.7660444, 0.7649214, 0.7637960, 0.7626683, 0.7615383, 0.7604060, 0.7592713, 0.7581343, 0.7569950, 0.7558535,
	0.7547096, 0.7535634, 0.7524149, 0.7512641, 0.7501111, 0.7489557, 0.7477981, 0.7466382, 0.7454760, 0.7443115,
	0.7431448, 0.7419759, 0.7408046, 0.7396311, 0.7384554, 0.7372773, 0.7360971, 0.7349146, 0.7337298, 0.7325429,
	0.7313537, 0.7301623, 0.7289686, 0.7277728, 0.7265747, 0.7253744, 0.7241718, 0.7229672, 0.7217602, 0.7205511,
	0.7193398, 0.7181263, 0.7169106, 0.7156927, 0.7144727, 0.7132505, 0.7120261, 0.7107995, 0.7095707, 0.7083398,
	0.7071068, 0.7058716, 0.7046342, 0.7033947, 0.7021530, 0.7009093, 0.6996634, 0.6984153, 0.6971651, 0.6959128,
	0.6946583, 0.6934018, 0.6921432, 0.6908824, 0.6896196, 0.6883546, 0.6870875, 0.6858183, 0.6845471, 0.6832737,
	0.6819984, 0.6807209, 0.6794413, 0.6781597, 0.6768760, 0.6755902, 0.6743024, 0.6730125, 0.6717206, 0.6704266,
	0.6691306, 0.6678326, 0.6665325, 0.6652303, 0.6639262, 0.6626200, 0.6613119, 0.6600016, 0.6586894, 0.6573752,
	0.6560590, 0.6547408, 0.6534206, 0.6520984, 0.6507742, 0.6494480, 0.6481199, 0.6467898, 0.6454577, 0.6441236,
	0.6427876, 0.6414496, 0.6401097, 0.6387678, 0.6374240, 0.6360782, 0.6347305, 0.6333808, 0.6320293, 0.6306758,
	0.6293204, 0.6279631, 0.6266038, 0.6252427, 0.6238796, 0.6225146, 0.6211478, 0.6197790, 0.6184084, 0.6170359,
	0.6156615, 0.6142852, 0.6129071, 0.6115270, 0.6101452, 0.6087614, 0.6073758, 0.6059884, 0.6045991, 0.6032080,
	0.6018150, 0.6004202, 0.5990236, 0.5976251, 0.5962249, 0.5948228, 0.5934188, 0.5920132, 0.5906057, 0.5891963,
	0.5877853, 0.5863723, 0.5849577, 0.5835412, 0.5821229, 0.5807030, 0.5792812, 0.5778576, 0.5764323, 0.5750052,
	0.5735764, 0.5721459, 0.5707135, 0.5692795, 0.5678437, 0.5664062, 0.5649670, 0.5635260, 0.5620834, 0.5606390,
	0.5591929, 0.5577451, 0.5562956, 0.5548444, 0.5533915, 0.5519370, 0.5504807, 0.5490228, 0.5475632, 0.5461019,
	0.5446390, 0.5431745, 0.5417082, 0.5402403, 0.5387707, 0.5372996, 0.5358268, 0.5343523, 0.5328763, 0.5313985,
	0.5299193, 0.5284383, 0.5269558, 0.5254716, 0.5239859, 0.5224986, 0.5210096, 0.5195191, 0.5180270, 0.5165333,
	0.5150381, 0.5135412, 0.5120428, 0.5105429, 0.5090414, 0.5075383, 0.5060337, 0.5045276, 0.5030199, 0.5015107,
	0.5000000, 0.4984877, 0.4969739, 0.4954586, 0.4939419, 0.4924235, 0.4909037, 0.4893824, 0.4878596, 0.4863354,
	0.4848096, 0.4832824, 0.4817537, 0.4802235, 0.4786919, 0.4771587, 0.4756242, 0.4740882, 0.4725508, 0.4710119,
	0.4694716, 0.4679298, 0.4663866, 0.4648420, 0.4632960, 0.4617486, 0.4601998, 0.4586495, 0.4570979, 0.4555449,
	0.4539905, 0.4524347, 0.4508775, 0.4493190, 0.4477591, 0.4461978, 0.4446352, 0.4430712, 0.4415058, 0.4399392,
	0.4383711, 0.4368018, 0.4352311, 0.4336591, 0.4320857, 0.4305111, 0.4289351, 0.4273578, 0.4257793, 0.4241994,
	0.4226182, 0.4210358, 0.4194521, 0.4178670, 0.4162808, 0.4146932, 0.4131044, 0.4115144, 0.4099230, 0.4083305,
	0.4067366, 0.4051416, 0.4035453, 0.4019477, 0.4003490, 0.3987491, 0.3971479, 0.3955455, 0.3939419, 0.3923371,
	0.3907311, 0.3891239, 0.3875156, 0.3859060, 0.3842953, 0.3826834, 0.3810704, 0.3794561, 0.3778408, 0.3762242,
	0.3746066, 0.3729878, 0.3713678, 0.3697467, 0.3681245, 0.3665012, 0.3648768, 0.3632512, 0.3616245, 0.3599968,
	0.3583679, 0.3567380, 0.3551069, 0.3534748, 0.3518416, 0.3502074, 0.3485720, 0.3469356, 0.3452982, 0.3436597,
	0.3420201, 0.3403795, 0.3387379, 0.3370952, 0.3354516, 0.3338068, 0.3321611, 0.3305144, 0.3288666, 0.3272179,
	0.3255681, 0.3239174, 0.3222657, 0.3206130, 0.3189593, 0.3173046, 0.3156490, 0.3139924, 0.3123349, 0.3106764,
	0.3090170, 0.3073566, 0.3056953, 0.3040331, 0.3023699, 0.3007058, 0.2990408, 0.2973749, 0.2957080, 0.2940403,
	0.2923717, 0.2907022, 0.2890318, 0.2873605, 0.2856884, 0.2840153, 0.2823414, 0.2806667, 0.2789911, 0.2773146,
	0.2756373, 0.2739592, 0.2722802, 0.2706004, 0.2689198, 0.2672384, 0.2655561, 0.2638730, 0.2621892, 0.2605045,
	0.2588190, 0.2571328, 0.2554457, 0.2537579, 0.2520693, 0.2503800, 0.2486898, 0.2469990, 0.2453074, 0.2436150,
	0.2419219, 0.2402280, 0.2385334, 0.2368381, 0.2351421, 0.2334453, 0.2317479, 0.2300497, 0.2283508, 0.2266513,
	0.2249510, 0.2232501, 0.2215485, 0.2198462, 0.2181432, 0.2164396, 0.2147353, 0.2130303, 0.2113248, 0.2096185,
	0.2079117, 0.2062041, 0.2044960, 0.2027873, 0.2010779, 0.1993679, 0.1976573, 0.1959461, 0.1942343, 0.1925219,
	0.1908089, 0.1890954, 0.1873813, 0.1856666, 0.1839513, 0.1822355, 0.1805191, 0.1788022, 0.1770847, 0.1753667,
	0.1736481, 0.1719291, 0.1702095, 0.1684893, 0.1667687, 0.1650476, 0.1633259, 0.1616038, 0.1598811, 0.1581580,
	0.1564344, 0.1547103, 0.1529858, 0.1512608, 0.1495353, 0.1478094, 0.1460830, 0.1443562, 0.1426289, 0.1409012,
	0.1391731, 0.1374445, 0.1357155, 0.1339861, 0.1322563, 0.1305261, 0.1287956, 0.1270646, 0.1253332, 0.1236014,
	0.1218693, 0.1201368, 0.1184039, 0.1166707, 0.1149371, 0.1132032, 0.1114689, 0.1097343, 0.1079993, 0.1062640,
	0.1045284, 0.1027925, 0.1010563, 0.0993197, 0.0975829, 0.0958457, 0.0941083, 0.0923705, 0.0906325, 0.0888943,
	0.0871557, 0.0854169, 0.0836778, 0.0819385, 0.0801989, 0.0784591, 0.0767190, 0.0749787, 0.0732382, 0.0714974,
	0.0697564, 0.0680152, 0.0662739, 0.0645323, 0.0627905, 0.0610485, 0.0593063, 0.0575640, 0.0558215, 0.0540788,
	0.0523359, 0.0505929, 0.0488497, 0.0471064, 0.0453629, 0.0436193, 0.0418756, 0.0401317, 0.0383878, 0.0366437,
	0.0348995, 0.0331551, 0.0314107, 0.0296662, 0.0279216, 0.0261769, 0.0244321, 0.0226873, 0.0209424, 0.0191974,
	0.0174524, 0.0157073, 0.0139621, 0.0122170, 0.0104717, 0.0087265, 0.0069812, 0.0052359, 0.0034906, 0.0017453,
	0.0000000};

//tan值，0-45°，间隔0.1°
const float tan_lookup[] = {
	0.0000000, 0.0017453, 0.0034907, 0.0052360, 0.0069814, 0.0087269, 0.0104724, 0.0122179, 0.0139635, 0.0157093,
	0.0174551, 0.0192010, 0.0209470, 0.0226932, 0.0244395, 0.0261859, 0.0279325, 0.0296793, 0.0314263, 0.0331734,
	0.0349208, 0.0366683, 0.0384161, 0.0401641, 0.0419124, 0.0436609, 0.0454097, 0.0471588, 0.0489082, 0.0506578,
	0.0524078, 0.0541581, 0.0559087, 0.0576596, 0.0594109, 0.0611626, 0.0629147, 0.0646671, 0.0664199, 0.0681732,
	0.0699268, 0.0716809, 0.0734354, 0.0751904, 0.0769458, 0.0787017, 0.0804581, 0.0822150, 0.0839724, 0.0857302,
	0.0874887, 0.0892476, 0.0910071, 0.0927672, 0.0945278, 0.0962891, 0.0980509, 0.0998133, 0.1015763, 0.1033399,
	0.1051042, 0.1068692, 0.1086348, 0.1104010, 0.1121680, 0.1139356, 0.1157039, 0.1174730, 0.1192428, 0.1210133,
	0.1227846, 0.1245566, 0.1263294, 0.1281030, 0.1298773, 0.1316525, 0.1334285, 0.1352053, 0.1369830, 0.1387615,
	0.1405408, 0.1423211, 0.1441022, 0.1458842, 0.1476671, 0.1494510, 0.1512358, 0.1530215, 0.1548082, 0.1565958,
	0.1583844, 0.1601741, 0.1619647, 0.1637563, 0.1655489, 0.1673426, 0.1691373, 0.1709331, 0.1727300, 0.1745279,
	0.1763270, 0.1781271, 0.1799284, 0.1817308, 0.1835343, 0.1853390, 0.1871449, 0.1889520, 0.1907602, 0.1925697,
	0.1943803, 0.1961922, 0.1980053, 0.1998197, 0.2016354, 0.2034523, 0.2052705, 0.2070900, 0.2089109, 0.2107331,
	0.2125566, 0.2143814, 0.2162076, 0.2180353, 0.2198643, 0.2216947, 0.2235265, 0.2253597, 0.2271944, 0.2290306,
	0.2308682, 0.2327073, 0.2345479, 0.2363900, 0.2382336, 0.2400788, 0.2419255, 0.2437737, 0.2456236, 0.2474750,
	0.2493280, 0.2511827, 0.2530389, 0.2548968, 0.2567564, 0.2586176, 0.2604805, 0.2623451, 0.2642114, 0.2660794,
	0.2679492, 0.2698207, 0.2716940, 0.2735691, 0.2754459, 0.2773246, 0.2792050, 0.2810873, 0.2829715, 0.2848575,
	0.2867454, 0.2886352, 0.2905269, 0.2924205, 0.2943160, 0.2962135, 0.2981130, 0.3000144, 0.3019178, 0.3038232,
	0.3057307, 0.3076402, 0.3095517, 0.3114653, 0.3133810, 0.3152988, 0.3172187, 0.3191407, 0.3210649, 0.3229912,
	0.3249197, 0.3268504, 0.3287833, 0.3307184, 0.3326557, 0.3345953, 0.3365372, 0.3384813, 0.3404278, 0.3423765,
	0.3443276, 0.3462811, 0.3482369, 0.3501950, 0.3521556, 0.3541186, 0.3560840, 0.3580518, 0.3600222, 0.3619950,
	0.3639703, 0.3659481, 0.3679284, 0.3699113, 0.3718967, 0.3738847, 0.3758753, 0.3778685, 0.3798644, 0.3818629,
	0.3838641, 0.3858679, 0.3878745, 0.3898837, 0.3918958, 0.3939105, 0.3959280, 0.3979484, 0.3999715, 0.4019975,
	0.4040262, 0.4060579, 0.4080924, 0.4101299, 0.4121703, 0.4142136, 0.4162598, 0.4183091, 0.4203613, 0.4224165,
	0.4244748, 0.4265362, 0.4286006, 0.4306681, 0.4327387, 0.4348124, 0.4368893, 0.4389693, 0.4410526, 0.4431390,
	0.4452287, 0.4473216, 0.4494178, 0.4515173, 0.4536201, 0.4557263, 0.4578358, 0.4599486, 0.4620649, 0.4641846,
	0.4663077, 0.4684343, 0.4705643, 0.4726979, 0.4748349, 0.4769756, 0.4791198, 0.4812675, 0.4834189, 0.4855739,
	0.4877326, 0.4898950, 0.4920610, 0.4942308, 0.4964043, 0.4985816, 0.5007627, 0.5029476, 0.5051364, 0.5073290,
	0.5095255, 0.5117259, 0.5139302, 0.5161385, 0.5183508, 0.5205671, 0.5227874, 0.5250118, 0.5272402, 0.5294728,
	0.5317094, 0.5339503, 0.5361953, 0.5384445, 0.5406980, 0.5429557, 0.5452177, 0.5474840, 0.5497547, 0.5520297,
	0.5543091, 0.5565929, 0.5588811, 0.5611739, 0.5634711, 0.5657728, 0.5680791, 0.5703899, 0.5727055, 0.5750255,
	0.5773503, 0.5796797, 0.5820139, 0.5843529, 0.5866965, 0.5890451, 0.5913984, 0.5937566, 0.5961197, 0.5984877,
	0.6008607, 0.6032386, 0.6056216, 0.6080096, 0.6104027, 0.6128008, 0.6152042, 0.6176126, 0.6200263, 0.6224452,
	0.6248694, 0.6272988, 0.6297336, 0.6321738, 0.6346193, 0.6370703, 0.6395267, 0.6419886, 0.6444560, 0.6469290,
	0.6494076, 0.6518918, 0.6543817, 0.6568772, 0.6593785, 0.6618856, 0.6643984, 0.6669172, 0.6694417, 0.6719722,
	0.6745085, 0.6770510, 0.6795994, 0.6821538, 0.6847143, 0.6872810, 0.6898538, 0.6924329, 0.6950181, 0.6976097,
	0.7002076, 0.7028118, 0.7054224, 0.7080395, 0.7106630, 0.7132931, 0.7159297, 0.7185729, 0.7212228, 0.7238793,
	0.7265425, 0.7292126, 0.7318894, 0.7345731, 0.7372636, 0.7399611, 0.7426656, 0.7453771, 0.7480956, 0.7508213,
	0.7535541, 0.7562941, 0.7590414, 0.7617959, 0.7645578, 0.7673270, 0.7701037, 0.7728879, 0.7756795, 0.7784788,
	0.7812857, 0.7841002, 0.7869225, 0.7897524, 0.7925903, 0.7954360, 0.7982895, 0.8011511, 0.8040207, 0.8068983,
	0.8097841, 0.8126780, 0.8155801, 0.8184906, 0.8214093, 0.8243364, 0.8272720, 0.8302161, 0.8331686, 0.8361299,
	0.8390997, 0.8420782, 0.8450655, 0.8480617, 0.8510668, 0.8540807, 0.8571037, 0.8601357, 0.8631769, 0.8662272,
	0.8692868, 0.8723556, 0.8754339, 0.8785215, 0.8816186, 0.8847253, 0.8878416, 0.8909676, 0.8941032, 0.8972488,
	0.9004041, 0.9035694, 0.9067447, 0.9099301, 0.9131255, 0.9163312, 0.9195472, 0.9227735, 0.9260102, 0.9292574,
	0.9325152, 0.9357835, 0.9390625, 0.9423524, 0.9456530, 0.9489646, 0.9522872, 0.9556208, 0.9589655, 0.9623215,
	0.9656888, 0.9690675, 0.9724575, 0.9758592, 0.9792724, 0.9826973, 0.9861340, 0.9895825, 0.9930430, 0.9965155,
	1.0000000};

float Sin_Lookup(float angle)
{
	int angle_temp = (int)(angle * 10.0f) % 3600;

	if (angle_temp < 0)
		angle_temp += 3600;				  //缩放到0-360°
	int k = (angle_temp > 1800) ? -1 : 1; //保存比例系数
	angle_temp %= 1800;					  //缩放到0-180°
	if (angle_temp > 900)
		angle_temp = 1800 - angle_temp; //关于90°对称

	return sin_lookup[angle_temp] * k;
}

float Cos_Lookup(float angle)
{
	return Sin_Lookup(90.0f - angle); //sin和cos的相位差90°
									  //int angle_temp = (int)(angle*10.0) % 3600;

	//if (angle_temp < 0)angle_temp += 3600;//缩放到0-360°
	//int k = (angle_temp > 1800) ? 1 : -1;	//保存比例系数
	//angle_temp /= 1800;	//缩放到0-180°
	//if (angle_temp > 900)angle_temp = 1800 - angle_temp;	//关于90°对称

	//return sin_lookup[angle_temp] * k;
}

float Tan_Lookup(float angle)
{
	int angle_temp = (int)(angle * 10.0f) % 1800;
	if (angle_temp < 0)
		angle_temp += 1800;				 //缩放到0-180°
	int k = (angle_temp > 900) ? -1 : 1; //保存比例系数
	if (angle_temp > 450)
	{
		angle_temp = 900 - angle_temp;
		return 1.0f / tan_lookup[angle_temp];
	}
	else
	{
		return tan_lookup[angle_temp];
	}
}

int ArcSin_Lookup(float value)
{
	int index;
	index = Dichotomization_Lookup_Angle(0, 900, sin_lookup, value);
	return index; //放大了十倍
}

int ArcCos_Lookup(float value)
{
	int index;
	index = Dichotomization_Lookup_Angle(0, 900, cos_lookup, value);
	return index; //放大了十倍
}

int ArcTan_Lookup(float x, float y)
{
	int k = (ABS(x) < ABS(y)) ? 0 : 1; //k=0表示x<y，即角度大于45°
	int index;
	float value;
	if (k)
		value = y / x;
	else
		value = x / y;

	index = Dichotomization_Lookup_Angle(0, 450, tan_lookup, ABS(value));
	if (!k)
		index = 900 - index;

	if ((x >= 0.0f) && (y >= 0.0f)) //第一象限
	{
		return index;
	}
	if ((x <= 0.0f) && (y >= 0.0f)) //第二象限
	{
		return 1800 - index;
	}
	if ((x <= 0.0f) && (y <= 0.0f)) //第三象限
	{
		return 1800 + index;
	}
	if ((x >= 0.0f) && (y <= 0.0f)) //第四象限
	{
		return 3600 - index;
	}
}

//************************************
// Method:    Dichotomization_Lookup_Angle
// FullName:  Dichotomization_Lookup_Angle
// Access:    public
// Returns:   int 对应解的下标
// Parameter: int left	左端初值下标
// Parameter: int right 右端初值下标
// Parameter: float * form 表地址
// Parameter: float solution 需要的解
// Description:	二分法查表,在规定范围内，三角函数是单调的,故终止条件设为误差小于0.000001
//
//************************************
int Dichotomization_Lookup_Angle(int left, int right, const float *form, float solution)
{
	int middle = left;
	float value = 0.0f;

	value = *(form + left);
	//检查解不在初值处
	if (ABS(value - solution) < 0.000001)
	{
		return left;
	}
	value = *(form + right);
	if (ABS(value - solution) < 0.000001)
	{
		return right;
	}

	while (left < right - 1)
	{
		middle = (left + right) >> 1; //取中值
		value = *(form + middle);
		//检查解是否落在中值上
		if (ABS(value - solution) < 0.000001)
		{
			return middle;
		}

		if (value > solution)
		{
			right = middle;
		}
		else
		{
			left = middle;
		}
	}
	if (ABS(*(form + left) - solution) < ABS(*(form + right) - solution))
	{
		return left;
	}
	else
		return right;
}
